package com.swordget.conf;

import com.swordget.filter.CharsetFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * on 2020/4/5 13:59
 *
 * @author David
 */
@Configuration
public class WebConfig {

    @Bean
    public FilterRegistrationBean<CharsetFilter> filterRegistrationBean() {
        FilterRegistrationBean<CharsetFilter> registration = new FilterRegistrationBean<>();
        registration.setFilter(new CharsetFilter());
        //配置过滤路径
        registration.addUrlPatterns("/*");
        //设置filter名称
        registration.setName("myFilter");
        //请求中过滤器执行的先后顺序，值越小越先执行
        registration.setOrder(1);
        return registration;
    }

}
